<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>

      // 使用Function.prototype.call 和 Function.prototype.apply 则可以动态的改变this指向
      var obj1 = {
        name: "sven",
        getName: function () {
          return this.name;
        },
      };

      var obj2 = {
        name: "anne",
      };

      console.log(obj1.getName()); // 输出： sven
      console.log(obj1.getName.call(obj2)); // 输出：anne
    </script>
  </body>
</html>
